import { defineConfig } from 'vite'
import { resolve } from 'path'

import vue from '@vitejs/plugin-vue'

function pathResolve(dir: string) {
  return resolve(process.cwd(), '.', dir)
}

// https://vitejs.dev/config/
export default defineConfig({
  resolve: {
    alias: [
      {
        find: /\@\//,
        replacement: pathResolve('src') + '/',
      },
    ],
  },
  server: {
    proxy: {
      '^/api/.*': {
        target: 'htpp://localhost:9080',
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/api/, ''),
      },
    },
  },
  // proxy: {
  //   '/api': {
  //
  //
  //     //
  //   },
  // },
  build: {
    assetsDir: 'static',
    emptyOutDir: true,
  },
  plugins: [vue()],
})
